﻿Public Class Form3
    Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        txtMaxRecords.Text = My.Settings.MaxRows.ToString
        txtAuthors.Text = My.Settings.Author
        txtFilter.Text = My.Settings.TopicFilter
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Close()
    End Sub

    Private Sub txtMaxRecords_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtMaxRecords.KeyPress
        If Asc(e.KeyChar) <> 8 Then
            If Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then
                e.Handled = True
            End If
        End If
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim bChanges As Boolean = False

        If txtMaxRecords.MaxLength < 1 Then
            txtMaxRecords.Text = My.Settings.MaxRows.ToString
        End If

        If CInt(txtMaxRecords.Text) = 0 Then
            txtMaxRecords.Text = My.Settings.MaxRows.ToString
        Else
            bChanges = True
            My.Settings.MaxRows = CInt(txtMaxRecords.Text)
        End If

        My.Settings.Author = txtAuthors.Text
        My.Settings.TopicFilter = txtFilter.Text


        MsgBox("Settings saved successfully", MsgBoxStyle.Information, "Save Settings")
    End Sub

End Class